package com.qiche.controller.mini;

import com.qiche.aspect.Result;
import com.qiche.enums.ResultEnum;
import com.qiche.model.StoreMemberCar;
import com.qiche.service.StoreMemberCarService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author chendezhi
 * @date 2018/3/28 11:21
 * 车辆信息管理控制器【微信小程序会员端】
 */
@RestController
@RequestMapping("/membercar/mini")
public class MemberCarMiniController {
    private Logger logger = LoggerFactory.getLogger(getClass());
    @Autowired
    private StoreMemberCarService storeMemberCarService;
    /**
     * 添加会员车辆
     * @param storeMemberCar
     * @return
     */
    @PostMapping("/add")
    public Result userAddStoreMemberCar(@RequestBody StoreMemberCar storeMemberCar){
        return storeMemberCarService.saveOrUpdate(storeMemberCar);
    }

    /**
     *  获取客户车辆列表 【带排序】
     * @param storeMemberId
     * @return
     */
    @GetMapping("/getList/{storeMemberId}")
    public Result userGetStoreMemberCar(@PathVariable("storeMemberId")Long storeMemberId){
        List<StoreMemberCar> customerCarList= storeMemberCarService.getCarsByStoreMemberId(storeMemberId);
        return Result.createByResultEnum(ResultEnum.SUCCESS,customerCarList);
    }

    /**
     * 添加会员车辆
     * @param storeMemberCarId
     * @return
     */
    @DeleteMapping("/delete/{id}")
    public Result deleteStoreMemberCar(@PathVariable("id") Long storeMemberCarId){
        return  storeMemberCarService.delete(storeMemberCarId);
    }

}
